package com.ccsoft.atools.utils;


import org.springframework.http.HttpStatus;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * @ClassName:GlobalExceptionHandler
 * @Description:TODO
 * @Author:chanchaw
 * @Date:2019-12-23 8:37
 * @Version:1.0
 **/
@ControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(BusinessException.class)
    public JsonResult handleBusinessException(BusinessException ex) {
        String msg = ex.getMsg();
        return JsonResult.error(msg);
    }

//    @ResponseBody
//    @ExceptionHandler(Exception.class)
//    public JsonResult handleBusinessException(Exception ex){
//        System.out.println("抛出的异常是：");
//        System.out.println(ex);
//
//        String msg = ex.getMessage();
//        return JsonResult.error(msg);
//    }
}
